from imageai.Detection.Custom import CustomVideoObjectDetection
import os

execution_path = os.getcwd()

video_detector = CustomVideoObjectDetection()
video_detector.setModelTypeAsYOLOv3()
video_detector.setModelPath(r"D:\Data_Folder\git_rep\ImageAI\examples\hololens-ex-60--loss-2.76.h5") # download via https://github.com/OlafenwaMoses/ImageAI/releases/download/essential-v4/hololens-ex-60--loss-2.76.h5
video_detector.setJsonPath(r"D:\Data_Folder\git_rep\ImageAI\examples\detection_config.json") # download via https://github.com/OlafenwaMoses/ImageAI/releases/download/essential-v4/detection_config.json
video_detector.loadModel()

video_detector.detectObjectsFromVideo(input_file_path=r"D:\Data_Folder\git_rep\ImageAI\examples\holo1.mp4",
                                          output_file_path=os.path.join(execution_path, "holo1-detected3"),
                                          frames_per_second=10,
                                          minimum_percentage_probability=40,
                                          log_progress=True)